From 230e94533a03ef7b9980a85709419ca2bf52f5f7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 3 Nov 2015 06:39:09 +0000 Subject: [PATCH] Convert ChangesList from MapCacheLRU to HashBagOStuff Also make use of getWithSetCallback() while at it. Change-Id: I6bd29db7c6564fcaf4489ec0f226ac83bafc75e8 --- includes/changes/ChangesList.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 9ac6c326a9..2494ef1098 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -36,8 +36,8 @@ class ChangesList extends ContextSource { protected $rclistOpen; protected $rcMoveIndex; - /** @var MapCacheLRU */ - protected $watchingCache; + /** @var BagOStuff */ + protected $watchMsgCache; /** * Changeslist constructor @@ -53,7 +53,7 @@ class ChangesList extends ContextSource { $this->skin = $obj; } $this->preCacheMessages(); - $this->watchingCache = new MapCacheLRU( 50 ); + $this->watchMsgCache = new HashBagOStuff( array( 'maxKeys' => 50 ) ); } /** @@ -500,17 +500,17 @@ class ChangesList extends ContextSource { * @return string */ protected function numberofWatchingusers( $count ) { - $cache = $this->watchingCache; - if ( $count > 0 ) { - if ( !$cache->has( $count ) ) { - $cache->set( $count, $this->msg( 'number_of_watching_users_RCview' ) - ->numParams( $count )->escaped() ); - } - - return $cache->get( $count ); - } else { + if ( $count <= 0 ) { return ''; } + $cache = $this->watchMsgCache; + $that = $this; + return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE, + function () use ( $that, $count ) { + return $that->msg( 'number_of_watching_users_RCview' ) + ->numParams( $count )->escaped(); + } + ); } /** -- 2.20.1